﻿namespace TestUp.Models.ShortEntities
{
    public static class EntitiesConversionExtensions
    {
        public static ShortUserInfo ConvertToShortEntity(this UserInfo userInfo)
        {
            var shortUserInfo = EntitiesConverter.ToShortEntity<ShortUserInfo, UserInfo>(userInfo);
            shortUserInfo.Group = userInfo.Group.ConvertToShortEntity();
            shortUserInfo.Permission = userInfo.Permission.ConvertToShortEntity();

            return shortUserInfo;
        }

        public static ShortPermission ConvertToShortEntity(this Permission permission)
        {
            var shortPermission = EntitiesConverter.ToShortEntity<ShortPermission, Permission>(permission);

            return shortPermission;
        }

        public static ShortGroup ConvertToShortEntity(this Group group)
        {
            var shortGroup = EntitiesConverter.ToShortEntity<ShortGroup, Group>(group);

            return shortGroup;
        }

        public static ShortCourse ConvertToShortEntity(this Course course)
        {
            var shortCourse = EntitiesConverter.ToShortEntity<ShortCourse, Course>(course);

            return shortCourse;
        }

        public static ShortPendingTest ConvertToShortEntity(this PendingTest pendingTest)
        {
            var shortPendingTest = EntitiesConverter.ToShortEntity<ShortPendingTest, PendingTest>(pendingTest);
            shortPendingTest.Group = pendingTest.Group.ConvertToShortEntity();
            shortPendingTest.Test = pendingTest.Test.ConvertToShortEntity();

            return shortPendingTest;
        }

        public static ShortTest ConvertToShortEntity(this Test test)
        {
            var shortTest = EntitiesConverter.ToShortEntity<ShortTest, Test>(test);
            shortTest.Course = test.Course.ConvertToShortEntity();

            return shortTest;
        }
    }
}